home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13542 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mail2news.demon.co.uk!tsys.demon.co.uk
  2. From: Tom Wheeley <tomw@tsys.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Q: free() function
  5. Date: Mon, 08 Apr 96 06:50:36 GMT
  6. Organization: City Zen FM
  7. Message-ID: <828946236snz@tsys.demon.co.uk>
  8. References: <4k9ai7$rck@tibalt.supernet.ab.ca>
  9. Reply-To: tomw@tsys.demon.co.uk
  10. X-NNTP-Posting-Host: tsys.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.30
  12. X-Sig-By: Tomsystems Quote v1.2.  (c)1996 Tom Wheeley, tomw@tsys.demon.co.uk
  13. X-Mail2News-Path: tsys.demon.co.uk
  14.  
  15. In article <4k9ai7$rck@tibalt.supernet.ab.ca>
  16.            lts@news.supernet.ab.ca "Len Starrenburg" writes:
  17.  
  18. > When dynamically allocating memory for a series of strings and storing 
  19. > the addresses in a char pointer array, can all the allocated memory be 
  20. > freed simply using "free(array)" or does "free(array[x])" have to be 
  21. > executed for each pointer in the array.
  22. > I think the latter would be correct but I'm not 100% sure, please comment.
  23.  
  24. Tou will need the latter followed by the former.  The latter will remove
  25. each string, whereas the former will remove the array of pointers.
  26.  
  27. Just doing the former will leave you with x strings floating in memory at some
  28. inaccessible location.
  29.  
  30. .splitbung
  31. -- 
  32. * TQ 1.0 * The 'Just So Quotes'.
  33. I don't want to achieve immortality through my work. I want to achieve 
  34. immortality through not dying."
  35.     -- Woody Allen
  36.